package cn.accp.sartwar.baseEntity;

//英雄
public abstract class Hero {
	// 英雄名
	protected String name;
	// 体重值
	protected int weight;
	// 法力值
	protected int magic;

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the magic
	 */
	public int getMagic() {
		return magic;
	}

	/**
	 * @param magic
	 *            the magic to set
	 */
	public void setMagic(int magic) {
		if (magic > 0) {
			this.magic = magic;
		}
	}

	/**
	 * @return the weight
	 */
	public int getWeight() {
		return weight;
	}

	/**
	 * @param weight
	 *            the weight to set
	 */
	public void setWeight(int weight) {
		if (weight > 0) {
			this.weight = weight;
		}
	}

	public Hero() {
	}

	/**
	 * 
	 * @param name
	 *            英雄名
	 * @param weight
	 *            体重
	 * @param magic
	 *            法力值
	 */
	public Hero(String name, int weight, int magic) {
		this.name = name;
		setMagic(magic);
		setWeight(weight);
	}

	public abstract void attack();

	public abstract void run();

	public abstract void jump();

	/**
	 * 判断是否与当前类属性值相等
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Hero) {
			Hero hero = (Hero) obj;
			return hero.magic == this.magic && hero.weight == this.weight
					&& hero.name.equals(this.name);
		} else {
			return false;
		}
	}

	/**
	 * 重写的toString方法
	 */
	@Override
	public String toString() {
		return "英雄名：" + this.name + "，体重：" + this.weight + "，法力值：" + this.magic;
	}
}
